/**
 * Sortable.java
 */
package com.mht2017.common.api;

import java.util.Comparator;

/**
 * @author Ziv
 */
public interface Sortable {

	SortableComparator comparator = new SortableComparator();

	int index();

	static class SortableComparator implements Comparator<Sortable> {

		@Override
		public int compare(Sortable o1, Sortable o2) {
			if (null != o1 && null != o2) {
				return o1.index() - o2.index();
			} else if (null != o1) {
				return 1;
			} else if (null != o2) {
				return -1;
			} else {
				return 0;
			}
		}

	}
}
